package com.poisonh.unifiedauth.dialog;

import android.annotation.SuppressLint;
import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;

import com.poisonh.unifiedauth.R;
import com.poisonh.unifiedauth.ui.IdCardSettingActivity;
import com.poisonh.unifiedauth.ui.MainActivity;
import com.poisonh.unifiedauth.ui.svprogresshud.SVProgressHUD;

/**
 * 新增名片
 * Created by WangDi on 2017/3/13.
 */
public class AddCardDialogFragment extends DialogFragment implements View.OnClickListener
{
    private Button mBtnCancel;
    private Button mBtnSignOut;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        @SuppressLint("InflateParams")
        View view = inflater.inflate(R.layout.layout_dialog_addcard, null);
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState)
    {
        super.onViewCreated(view, savedInstanceState);
        mBtnCancel = (Button) view.findViewById(R.id.btn_cancel);
        mBtnSignOut = (Button) view.findViewById(R.id.btn_signout);
        mBtnCancel.setOnClickListener(this);
        mBtnSignOut.setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
        switch (v.getId()) {
            case R.id.btn_cancel:
                this.dismiss();
                SVProgressHUD.dismiss(getActivity());
                break;
            case R.id.btn_signout:
//                Intent setHeadIntent = new Intent(getActivity(), SettingCardActivity.class);// 注册流程增加头像
//                setHeadIntent.putExtra("code", "1");
//                setHeadIntent.putExtra("PHONE", getActivity().getIntent().getStringExtra("PHONE"));
                Intent addIdCardIntent = new Intent(getActivity(), IdCardSettingActivity.class);// 新增身份证信息
               // startActivity(addIdCardIntent);
                startActivityForResult(addIdCardIntent,0);
                this.dismiss();

//                startActivity(setHeadIntent);
                //切换时的动画
                getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                SVProgressHUD.dismiss(getActivity());
                //getActivity().finish();
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch(resultCode){
            case 0:
                if(data!=null){
                    int delete_location=data.getIntExtra("delete_location",-1);
                }


            case 2:
                // NewActivity的返回数据
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
}
